package com.hellogood.yaohuo.server.serviceImpl;

import java.util.LinkedHashMap;
import java.util.List;

import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.hellogood.yaohuo.server.mgr.factory.MgrFactory;
import com.hellogood.yaohuo.shared.entity.Color;
import com.hellogood.yaohuo.shared.services.ColorService;

@SuppressWarnings("serial")
public class ColorServiceImpl extends RemoteServiceServlet implements ColorService {

	@Override
	public List<Color> getAllColorList() {
		return MgrFactory.getInstance().createColorMgr().getAllColor();
	}

	@Override
	public String createColor(Color c) {
		return MgrFactory.getInstance().createColorMgr().addNewColor(c);
	}

	@Override
	public String deleteColor(Color c) {
		return MgrFactory.getInstance().createColorMgr().removeColor(c);
	}

	@Override
	public LinkedHashMap<String, String> getAllColorMap() {
		List<Color> colorList = getAllColorList();
		LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
		map.put("0", "0-均色");
		for (Color c : colorList) {
			map.put(c.getColorCode(), c.getColorCode() + "-" + c.getColorName());
		}
		return map;
	}

}
